package
{
	import com.e0box.game.logicGraphics.Game;
	
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageQuality;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	import acheGesture.GestureManager;
	
	import starling.core.Starling;
	
	[SWF(frameRate="60", backgroundColor="0x202020", width="640", height="960")]
	public class LogicGraphic extends Sprite
	{
		
		private var _starling:Starling;
		
		public function LogicGraphic()
		{
			if(stage) onDisplayed(null);
			else addEventListener(Event.ADDED_TO_STAGE,onDisplayed);
		}
		
		
		private function onDisplayed(evt:Event):void{
			if(evt) removeEventListener(Event.ADDED_TO_STAGE,onDisplayed);
			
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			stage.quality = StageQuality.BEST;
			
			if(stage.stageWidth) loadMaterials();
			else{
				stage.addEventListener(Event.RESIZE,function onResize(evT:Event):void{
					if(stage.stageWidth){	
						stage.removeEventListener(Event.RESIZE,onResize);
						loadMaterials();
					}
				});
			}
		}
		
		private function loadMaterials():void{
			
			init();
			return;
			
			/*var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function onLoaded(evt:Event):void{
				loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onLoaded);
				
				init();
			});
			loader.load(new URLRequest("assets/dev/materials.swf"),context);*/
			
		}
		
		private function init(): void {
			Starling.multitouchEnabled = true;
			
			_starling = new Starling(Game, stage);
			_starling.start();
			_starling.showStats = true;
			_starling.simulateMultitouch = true;
			
//			_starling.antiAliasing = 1;
			
		}
	}
}